package join;

//创建多线程
/*
 *1.继承Thread
 * 2.重写run方法
 * 3.创建线程实例
 * 4.启动线程
 **/
public class MyThread extends Thread {
    //构造函数，设置个名字
    private String name;

    public MyThread(String name) {
        this.name = name;
    }

    //run方法是线程要执行的代码逻辑
    @Override
    public void run() {
        int i = 1;
        while (i <= 5) {
            System.out.println(this.name + i++);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
